package com.haochang.chunkvod.app.utils;

import java.util.List;

import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;

/**
 *@author qintao
 *created at 2016/9/22 11:15
 * vod工具类
 */

public class VodUtils
{

	/**
	 * 判断移动设备是否安装了包名为packageName的应用
	 * @param activity
	 * @param packageName
	 * @return
	 */
	public static boolean isAvilible(Activity activity, String packageName)
	{
		boolean flag = false;
		PackageManager packageManager = activity.getPackageManager();// 获取packagemanager
		List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);// 获取所有已安装程序的包信息
		if (!CollectionUtils.isEmpty(pinfo))
		{
			for (int i = 0; i < pinfo.size(); i++)
			{
				String pn = pinfo.get(i).packageName;
				if (!TextUtils.isEmpty(pn) && pn.equals(packageName))
				{
					flag = true;
					break;
				}
			}
		}
		return flag;
	}
}
